NAME_EXE	= 	nibbler
SRC_EXE		= 	src/main.cpp \
		  	src/Nibbler.cpp \
			src/check_pos.cpp

OBJ_EXE		= $(SRC_EXE:.cpp=.o)


NAME_LIB_SFML	= lib_nibbler_SFML.so
SRC_LIB_SFML	= SFMLlib/SFML.cpp
OBJ_LIB_SFML	= $(SRC_LIB_SFML:.cpp=.o)

NAME_LIB_NC	= lib_nibbler_Ncurses.so
SRC_LIB_NC	= ./NCurseslib/Ncurses.cpp
OBJ_LIB_NC	= $(SRC_LIB_NC:.cpp=.o)

NAME_LIB_QT	= lib_nibbler_Qt.so

LDFLAGS += -ldl -lcurses -export-dynamic -lsfml-graphics -lsfml-window -lsfml-system
CXXFLAGS += -fPIC

CXX = g++

all: $(NAME_LIB_SFML) $(NAME_LIB_NC) GENERATE_LIB_QT $(NAME_EXE)

$(NAME_EXE): $(OBJ_EXE)
	$(CXX) -o $(NAME_EXE) $(OBJ_EXE) $(LDFLAGS)

$(NAME_LIB_SFML): $(OBJ_LIB_SFML)
	$(CXX) -shared -o $(NAME_LIB_SFML) $(OBJ_LIB_SFML)

$(NAME_LIB_NC): $(OBJ_LIB_NC)
	$(CXX) -shared -o $(NAME_LIB_NC) $(OBJ_LIB_NC)

GENERATE_LIB_QT:
		make -C ./qtlib && cp ./qtlib/$(NAME_LIB_QT) .

clean:
	rm -f $(OBJ_LIB_SFML) $(OBJ_EXE) $(OBJ_LIB_NC) $(OBJ_LIB_QT)
	make clean -C ./qtlib

fclean: clean
	rm -f $(NAME_EXE) $(NAME_LIB_SFML) $(NAME_LIB_NC) $(NAME_LIB_QT)

re: fclean all
